package com.jic.order.model;

import com.jic.order.model.domain.BuyerModel;
import com.jic.order.model.domain.OrderDeliverModel;
import com.jic.order.model.domain.OrderGoodsModel;
import com.jic.order.model.domain.SellerModel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class OrderModel implements Serializable {

	// 主键ID
	private long id;
	// 流水号
	private String serialNo;
	// 订单父编号
	private String parentOrderNo;
	// 订单编号
	private String orderNo;
	// 订单类型
	private Integer orderType;
	// 冗余-销售渠道
	private Integer saleChannel;
	// 订单标签，VIP、紧急、特别、关注、搁置
	private Integer orderTag;
	// 下单时间
	private Date buyTime;
	// 销售总金额
	private BigDecimal saleTotalAmount;
	// 优惠总金额，优惠金额=销售总金额-购买总金额
	private BigDecimal discountTotalAmount;
	// 购买总金额，购买总金额=销售总金额-优惠总金额
	private BigDecimal buyTotalAmount;
	// 物流总费
	private BigDecimal expressTotalFee;
	// 实付总金额，实付总金额=购买总金额+物流费
	private BigDecimal actualPayTotalAmount;
	// 备注
	private String mark;
	// 订单状态，初始化、确认收货、已完成、已关闭
	private Integer orderStatus;
	// 版本号
	private long version;
	// 卖家
	private SellerModel sellerModel;
	// 买家
	private BuyerModel buyerModel;
	// 优惠券列表
	private List<String> couponCodeList;
	// 商品
	private List<OrderGoodsModel> orderGoodsModelList = new ArrayList<>();
	// 交货单
	private List<OrderDeliverModel> orderDeliverModelList = new ArrayList<>();

	@ApiModelProperty("商品类型：1-常规商品;2卡券、3海购、4赠品、10实体卡、11虚拟卡、20券、 5生鲜产品、6增值服务、7其他、21积分商品;31-称重商品;41-虚拟充值")
	private Integer productType;

	/**
	 * 根据id查询OrderGoodsModel
	 */
	public OrderGoodsModel getOrderGoodsModelById(long id) {
		if (id == 0) {
			return null;
		}
		for (OrderGoodsModel orderGoodsModel : orderGoodsModelList) {
			if (id == orderGoodsModel.getId()) {
				return orderGoodsModel;
			}
		}
		return null;
	}
}
